#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void ShowResultImage(cv::Mat image);
    void ShowSourceImage(cv::Mat image);

    void OpenCamera();
    void CloseCanera();
    void SendVideoFrame();

    cv::Mat YCrCbOtsuDetect(cv::Mat &src);

    bool HandKeyPointsDetect(cv::Mat src, std::vector<cv::Point> &handKeyPoints);
    bool HandPoseRecognition(std::vector<cv::Point> &handKeyPoints, int &count);
    bool HandPoseShowResult(cv::Mat &src, std::vector<cv::Point> &handKeyPoints, int &count);

private:
    Ui::MainWindow *ui;
    QTimer timer;

    cv::VideoCapture camera;
    double contS, convexS;
    double areaK, arcK;
    cv::Mat frame, dst, morp, binary, imgbinary;
    std::vector<std::vector<cv::Point>> contours, contour;
    std::vector<double> area;

signals:
    void sign_VideoFrame(cv::Mat);

public slots:
    //contour detection
    void ContourDetection(cv::Mat image);
    //key-points detection
    void KeypointDetection(cv::Mat image);

private slots:
    void on_action_key_triggered();
    void on_action_con_triggered();
    void on_action_start_camera_triggered();
    void on_action_end_camera_triggered();
    void on_action_image_triggered();
};

#endif // MAINWINDOW_H
